package com.feng.util;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.Date;

/**
 * Created by HuangSuip on 2017/4/18.
 */
public class DateUtils {
    private static String YYYY_MM_DD = "yyyy-MM-dd";

    private static final ThreadLocal<DateFormat> df = new ThreadLocal<DateFormat>() {
        @Override
        protected DateFormat initialValue() {
            return df.get();
        }
    };

    public static DateFormat getSimpleDateFormat() {
        df.set(new SimpleDateFormat(""));
        return df.get();
    }

    public static String dateToString(Date date, String pattern){
        YYYY_MM_DD = pattern;
        return df.get().format(date);
    }

}
